#region Using directives
using System;
using System.Data ;
using WP.DB;
using WP.Commons;
using WP.MF.DataEntity; 
#endregion
namespace WP.MF.DataAccess
{

	/*
	 * Created by SmartCreateCode Tool
	 * At 4/22/2005
	 */

    public class MUserLocationDAL
	{
		public MUserLocationDAL()
		{
		}
		#region Select by Key
		public MUserLocationDEL SelectMUserLocationByKey(DBAccess dBAccess, int iRecId)
		{
			MUserLocationDEL mUserLocationDEL=new MUserLocationDEL();
			string strSql=string.Empty;
			object[] oValues;

			strSql=@"SELECT RecId,UserName,Location,LocationDesc,Access  FROM MUserLocation
 WHERE RecId={0}";

			oValues=new object[1];
			oValues[0]=iRecId;
			strSql=string.Format(strSql,oValues);
			dBAccess.GetDataSet(strSql,MUserLocationDEL.TABLENAME_MUSERLOCATION,mUserLocationDEL);
			return mUserLocationDEL;
		}
		#endregion

		#region Insert table by DataRow
		public void InsertMUserLocation(DBAccess dBAccess,MUserLocationDEL mUserLocationDEL)
		{
			string strSql=string.Empty;
			int iIndex=0;
			object[] oValues;

			DataRow DR=mUserLocationDEL.Tables[MUserLocationDEL.TABLENAME_MUSERLOCATION].Rows[0];
			strSql=@"INSERT INTO MUserLocation  (RecId,UserName,Location,LocationDesc,Access ) VALUES ( 
{0},'{1}','{2}','{3}',{4} )";

			oValues=new object[5];
			oValues[iIndex++]=DR[MUserLocationDEL.RECID].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.USERNAME].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.LOCATION].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.LOCATIONDESC].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.ACCESS].ToString();

			strSql=string.Format(strSql,oValues);

			dBAccess.ExecuteSql(strSql);
		}
		#endregion

		#region Update table by DataRow
		public void UpdateMUserLocation(DBAccess dBAccess,MUserLocationDEL mUserLocationDEL)
		{
			string strSql=string.Empty;
			int iIndex=0;
			object[] oValues;

			DataRow DR=mUserLocationDEL.Tables[MUserLocationDEL.TABLENAME_MUSERLOCATION].Rows[0];
			strSql=@"UPDATE MUserLocation SET UserName='{0}',Location='{1}',LocationDesc='{2}',
Access={3} 
 WHERE RecId={4}";

			oValues=new object[5];
			oValues[iIndex++]=DR[MUserLocationDEL.USERNAME].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.LOCATION].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.LOCATIONDESC].ToString();
			oValues[iIndex++]=DR[MUserLocationDEL.ACCESS].ToString();
			oValues[4]=DR[MUserLocationDEL.RECID].ToString();
			strSql=string.Format(strSql,oValues);

			dBAccess.ExecuteSql(strSql);
		}
		#endregion

		#region Delete table by Key
		public void DeleteMUserLocation(DBAccess dBAccess,int iRecId)
		{
			string strSql=string.Empty;

			strSql=@"DELETE FROM mUserLocation WHERE RecId="+iRecId;

			dBAccess.ExecuteSql(strSql);
		}
		#endregion

		#region Delete table by LocationNo
		public void DeleteMUserLocationbyLocationNo(DBAccess dBAccess,string strLocationNo)
		{
			string strSql=string.Empty;

			strSql="DELETE FROM mUserLocation WHERE Location='"+strLocationNo+"'";

			dBAccess.ExecuteSql(strSql);
		}
		#endregion

	}
}